from django.db import models

# Create your models here.
# models.py（修正版）
from django.db import models

class Publisher(models.Model):
    name = models.CharField(max_length=30)
    address = models.CharField(max_length=100)  # 补充缺失的 max_length

    def __str__(self):
        return self.name

class Book(models.Model):
    name = models.CharField(max_length=30)
    description = models.TextField(blank=True, null=True)
    publisher = models.ForeignKey(
        Publisher,
        on_delete=models.CASCADE  # 补充 on_delete 参数
    )
    add_date = models.DateField()

    def __str__(self):
        return self.name